//
//  home_QuestionTableViewCell.m
//  sellHouse
//
//  Created by 李 佳伟 on 2018/11/23.
//  Copyright © 2018年 李 佳伟. All rights reserved.
//

#import "home_QuestionTableViewCell.h"
#import "JTCSM.h"


@interface home_QuestionTableViewCell ()
{
    CGFloat cell_width;
    UIView *bottomview;
    UIView *lineview;
}
@property (nonatomic,strong) UILabel *contentLabel;

@end

@implementation home_QuestionTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentLabel = [UILabel initWithFrame:CGRectZero text:@"" font:14 textAlignment:NSTextAlignmentLeft texcolor:RGBACOLOR(151, 151, 151, 1) backgroundColor:nil];
        [self.contentView addSubview:self.contentLabel];
        self.contentView.backgroundColor = [UIColor whiteColor];
        bottomview = [[UIView alloc]initWithFrame:CGRectZero];
        [self.contentView addSubview:bottomview];
       lineview= [df lineViewWithHeightofTop:0 superView:self.contentView lineHeight:1 space:0];
    }
    
    return self;
}

- (void)setContentLabel_textWithText:(NSString *)text{
    cell_width = KSCREENWidth-2*Kspace;
    CGRect rect = [df labelHeightWithContent:text width:cell_width font:14];
    CGFloat changeheight = 0;
    if ([text containsString:@"在本页填写卖房信息或拨打400-622-6266联系我们。"]) {
        changeheight = 30*KSCREENWidth/375.0;
    }
    if ([text containsString:@"1、资深房产管家1对1服务，为房源精准估价。"]) {
        changeheight = 30*KSCREENWidth/375.0;
    }
    self.contentLabel.text = text;
    [self changeLineSpaceForLabel:self.contentLabel WithSpace:5];
    self.contentLabel.numberOfLines = 0;
    self.contentLabel.frame = CGRectMake(Kspace, 10, cell_width, rect.size.height+changeheight);
    bottomview.frame = CGRectMake(0, KVIEW_Y(self.contentLabel), KSCREENWidth-2*Kspace, 10);
    lineview.frame =  CGRectMake(0, KVIEW_Y(bottomview), KSCREENWidth, 1);
}

- (void)changeLineSpaceForLabel:(UILabel *)label WithSpace:(float)space {
    
    NSString *labelText = label.text;
    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:labelText];
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    [paragraphStyle setLineSpacing:space];
    [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [labelText length])];
    label.attributedText = attributedString;
    [label sizeToFit];
    
}

@end
